package com.honey.solr.daosupport.method;

import com.honey.compilation.java.JavaVisibility;
import com.honey.compilation.java.Method;
import com.honey.compilation.java.MethodDecoration;
import com.honey.compilation.java.Parameter;
import com.honey.core.types.FullyQualifiedJavaType;
import com.honey.generator.java.AbstractClassName;
import com.honey.solr.SolrFactory;

public class GreaterMethod extends AbstractClassName {
	
	private SolrFactory solrFactory = null; 
	
	public GreaterMethod(SolrFactory solrFactory ){
		this.solrFactory = solrFactory;
	}
	
	public Method createMethod(){
		
		Method answer = new Method("greater");
		answer.addJavaDocLine("Lucene >= 查询") ;
		MethodDecoration methodDecoration = answer.getDecoration();
		methodDecoration.setVisibility(JavaVisibility.PROTECTED);
		methodDecoration.setFinal(true);
		answer.setReturnType(new FullyQualifiedJavaType("StringBuilder"));
		Parameter parameter = new Parameter(solrFactory.getCriterionType(),"criterion");parameter.addJavaDocLine("查询条件");
		answer.addParameter(parameter);
		answer.addBodyLine("Object value = criterion.getValue()");	
		answer.addBodyLine("return between(criterion.getName(),value ==null ?null:value.toString() , null)");
		return answer ;
	}
}
